import { Column, DeleteDateColumn, Entity, JoinColumn, OneToOne, PrimaryColumn } from "typeorm";
import {UserEntity} from "../user/user.entity";

@Entity("at_task")
export class TaskEntity {
  @PrimaryColumn({ type: "uuid", generated: "uuid" })
  id: string;

  @Column({ type: "uuid", name: "module_id" })
  moduleId: string;

  @Column({ type: "uuid", name: "product_id" })
  productId: string;

  @Column({ type: "uuid", name: "parent_id" })
  parentId: string;

  @Column({ type: "varchar", name: "type" })
  type: string;

  @Column({ type: "text", name: "text" })
  text: string;
  @Column({ type: "bool", name: "done" })
  done: boolean;

  @Column({ type: "uuid", name: "user_id" })
  userId: string;

  @JoinColumn({ name: 'user_id' })
  @OneToOne(() => UserEntity, (entity) => entity.id)
  user: UserEntity;

  @Column({ type: "timestamptz", name: "expect_date" })
  expectDate: Date;

  @Column({ type: "timestamptz", name: "done_date" })
  doneDate: Date;

  @Column({ type: "timestamptz", name: "created_at" })
  createdAt: Date;

  @Column({ type: "varchar", name: "created_by" })
  createdBy: string;

  @Column({ type: "timestamptz", name: "updated_at" })
  updatedAt: Date;

  @Column({ type: "varchar", name: "updated_by" })
  updatedBy: string;

  @DeleteDateColumn({name: "deleted_at"})  deletedAt: Date;
}
